local renjie = fk.CreateSkill{
  name = "mod__renjie",
  frequency = Skill.Compulsory,
}
Fk:loadTranslationTable{
  ["mod__renjie"] = "忍戒",
  [":mod__renjie"] = "锁定技，当你受到伤害后/于出牌阶段外被弃置手牌后，你获得X枚“忍”（X为伤害值/你被弃置的手牌数）。",
  ["$mod__renjie1"] = "忍一时，风平浪静。",
  ["$mod__renjie2"] = "退一步，海阔天空。",
}
local renjieEffect = {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      if event == fk.Damaged then
        return target == player
      else
        if player.phase ~= Player.Play then
          for _, move in ipairs(data) do
            if move.from == player.id and move.moveReason == fk.ReasonDiscard then
              for _, info in ipairs(move.moveInfo) do
                if info.fromArea == Card.PlayerHand then
                  return true
                end
              end
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.Damaged then
      room:addPlayerMark(player, "@godsimayi_bear", data.damage)
    else
      local n = 0
      for _, move in ipairs(data) do
        if move.from == player.id and move.moveReason == fk.ReasonDiscard then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              n = n + 1
            end
          end
        end
      end
      room:addPlayerMark(player, "@godsimayi_bear", n)
    end
  end,
}
renjie:addEffect(fk.Damaged, renjieEffect)
renjie:addEffect(fk.Damaged, renjieEffect)
return renjie